package com.comm.ui.main;

import android.content.Intent;

import com.comm.ActivityDisplay;
import com.comm.base.BaseControllerImpl;
import com.comm.module.ApiServiceImpl;
import com.comm.update.UpdateInfo;

/**
 * Created by chenxunlin01 on 2017/9/21.
 */

public class MainController extends BaseControllerImpl<Mainconstant.View> implements Mainconstant.Controller {

    private ApiServiceImpl apiServiceImpl;
    private ActivityDisplay display;


    public MainController(Mainconstant.View view) {
        super(view);

    }

    @Override
    protected void init() {
        super.init();
        apiServiceImpl = beanManager.getApiServiceImpl();
        display = new ActivityDisplay(view.getActivity());
    }

    @Override
    public void onCreate(Intent intent) {
//        Subscription subscription = apiServiceImpl.fetchEvents(new BaseSubscriber<List<EventInfo>>() {
//
//            @Override
//            public void onBeforeStart() {
//                Log.e("MainController", "onBeforeStart");
//                view.showProgressView();
//            }
//
//            @Override
//            public void onError(Throwable e) {
//                Log.e("MainController", "onError",e);
//                view.showErrorView();
//            }
//
//            @Override
//            public void onNext(List<EventInfo> eventInfos) {
//                Log.e("MainController", eventInfos.size()+"");
//                view.showContent(eventInfos);
//            }
//
//        });
//        mCompositeSubscription.add(subscription);
        UpdateInfo updateInfo = new UpdateInfo();
        updateInfo.downloadUrl = "http://36.248.6.47/r/a.gdown.baidu.com/data/wisegame/5e7815ae05c2c3a4/xianjinbashi_2805.apk?from=a1101";
        updateInfo.isForce = false;
        updateInfo.des = "有应用升级";
        updateInfo.appSize = 8 * 1024 *1024;
        updateInfo.md5 = "dfe4a7655e7815ae05c2c3a420705f2e";
        display.startAppUpdateService(updateInfo);
    }

    @Override
    public void onDestroy() {
        mCompositeSubscription.unsubscribe();
    }
}
